package dshumsky.jooq;

import org.jooq.util.DefaultGenerator;
import org.jooq.util.GenerationTool;
import org.jooq.util.jaxb.Configuration;
import org.jooq.util.jaxb.Database;
import org.jooq.util.jaxb.Generator;
import org.jooq.util.jaxb.Jdbc;
import org.jooq.util.jaxb.Target;
import org.jooq.util.mysql.MySQLDatabase;

public class ClassGenerator {

	public static void main(String[] args) throws Exception {

		Configuration configuration = new Configuration();
		Jdbc jdbc = new Jdbc();
		jdbc.setDriver("com.mysql.jdbc.Driver");
		jdbc.setUser("root");
		jdbc.setPassword("password");
		jdbc.setUrl("jdbc:mysql://localhost:3306/bot");
		configuration.setJdbc(jdbc);
		Generator generator = new Generator();
		generator.setName(DefaultGenerator.class.getName());
		Target target = new Target();
		target.setDirectory("/opt/hg/dshumsky/jooq/src/main/java");
		target.setPackageName("dshumsky.jooq.generated");
		generator.setTarget(target);
		Database database = new Database();
		database.setName(MySQLDatabase.class.getName());
		database.setInputSchema("bot");
		database.setIncludes(".*");
		generator.setDatabase(database);
		configuration.setGenerator(generator);
		GenerationTool.generate(configuration);

	}

}
